<table class="layui-table">
    <colgroup>
        <col width="15%">
        <col width="10%">
        <col width="10%">
        <col width="15%">
        <col width="40%">
        <col width="8%">
    </colgroup>
    <thead>
        <tr>
            <th>参数名</th>
            <th>是否必选</th>
            <th>参数类型</th>
            <th>默认值</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td class="kgo-input-td"><input id="paramName" name="name" type="text" class="kgo-input-text"/></td>
            <td class="kgo-input-td">
                    <form class="layui-form" action="">
                            <div class="layui-form-item kgo-form-alone-item">
                                    <div class="layui-input-inline kgo-input-alone-inline">
                                    <select id="paramIsMust" name="isMust" lay-verify="required" lay-search="" :lay-filter="name">
                                        <option value="yes">是</option>
                                        <option value="no">否</option>
                                    </select>
                                    </div>
                            </div>
                    </form>
            </td>
            <td class="kgo-input-td">
                    <form class="layui-form" action="">
                            <div class="layui-form-item kgo-form-alone-item">
                                    <div class="layui-input-inline kgo-input-alone-inline">
                                    <select id="paramType" name="type" lay-verify="required" lay-search="" :lay-filter="name">
                                        <option value="String">String</option>
                                        <option value="int">int</option>
                                        <option value="bool">bool</option>
                                        <option value="double">double</option>
                                        <option value="float">float</option>
                                        <option value="array">数组</option>
                                        <option value="object">对象</option>
                                    </select>
                                    </div>
                            </div>
                    </form>
            </td>
            <td class="kgo-input-td"><input id="defaultValue" name="defaultValue" type="text" class="kgo-input-text"/></td>
            <td class="kgo-input-td"><input id="paramRemark" name="remark" type="text" class="kgo-input-text"/></td>
            <td class="kgo-input-td" style="text-align:center;">
                <div class="layui-btn-group">
                    <button class="layui-btn layui-btn-primary layui-btn-sm" id="addParams">
                        <i class="layui-icon">&#xe605;</i>
                    </button>
                </div>
            </td>
        </tr>
    </tbody>
</table>
<script type="text/javascript">
   var $ = layui.$;
   var _oldParamId = null;
   if(KgoUtil.getState("editThisParam")!=null){
     var _thisParam = KgoUtil.getState("editThisParam");
      console.log("asdfhasdfjlsdjfasdfjhsd-----------------");
      var _name = $('#paramName').val(_thisParam.name);
      var _isMust = $('#paramIsMust').val(_thisParam.isMust);
      var _type = $('#paramType').val(_thisParam.type);
      var _defaultValue = $('#defaultValue').val(_thisParam.defaultValue);
      var _remark = $('#paramRemark').val(_thisParam.remark);
      _oldParamId = _thisParam.id;
      KgoUtil.setState("editThisParam",null);
   }
   layui.form.render('select');

   function getParams(){
      var _name = $('#paramName').val();
      var _isMust = $('#paramIsMust').val();
      var _type = $('#paramType').val();
      var _defaultValue = $('#defaultValue').val();
      var _remark = $('#paramRemark').val();
      var timestampAsParamId =null;
      if(_oldParamId===null){
        timestampAsParamId = new Date().getTime();
      }else{
        timestampAsParamId = _oldParamId;
      }

     // console.log("时间戳  ： "+timestampAsParamId);
      var params={
        "id":timestampAsParamId,
        "name":_name,
        "isMust":_isMust,
        "type":_type,
        "defaultValue":_defaultValue,
        "remark":_remark
      };
      KgoUtil.setState("InterfaceParam",params);
     // console.log(JSON.stringify(params));
   }

   $('#addParams').on('click',function(){
      getParams();
      layer.closeAll();
   })
    $(function() {

    });
</script>
